<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('area', function (Blueprint $table) {
			$table->id();
			$table->string('name')->comment('区域名称');
			$table->char('letter')->comment('区域名称首字母');
			$table->string('name_uy')->default('')->comment('区域名称-维语');
			$table->string('letter_uy')->default('')->comment('区域名称首字母-维语');
			$table->string('adcode')->comment('区域编码');
			$table->string('parent_code')->comment('上级区域编码');
			$table->string('citycode')->comment('城市编码');
			$table->string('level')->comment('行政区划级别');
			$table->string('center')->default('')->comment('城市中心坐标');
			$table->tinyInteger('type')->default(0)->comment('类型 1 自治区 2 直辖市 3 省直辖县');
			$table->timestamps();
			$table->unique('adcode', 'unique_adcode');
			$table->index(['parent_code', 'adcode'], 'idx_code');
			$table->index('name', 'idx_name');
			$table->index('level', 'idx_level');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::dropIfExists('area');
	}
};
